<template>
	<view class="page">
		<view v-if="userInfo.flag == 1" class="sign-result">
			<uni-icons class="sign-result_icon" type="checkmarkempty" size="50" color="#13BC75" />
			<view>考勤成功</view>
		</view>

		<view v-if="userInfo.flag == 0" class="sign-result">
			<uni-icons class="sign-result_icon" type="close" size="50" color="#ff5500" />
			<view>考勤失败</view>
		</view>
		<view class="container">

			<!-- <uni-icons class="container-icons" type="camera-filled" size="100" color="#666" />
			<view class="container-tip">人脸正面照</view>
			<uni-file-picker class="group-info_upload" :imageStyles="imageStyles" limit="1" @select="select"
				@progress="progress" @success="success" @fail="fail">
			</uni-file-picker> -->
			<view class="image">
				<image :src="userInfo.imgSrc" mode="aspectFill"></image>
			</view>
		</view>

		<view v-if="userInfo.flag == 1" class="sign-text">
			<view v-if="userInfo.clockType == 1">
				<view class="sign-text_item">进场时间：{{recordDate}}</view>
				<view class="sign-text_item">打卡地点：{{userInfo.address}}</view>
			</view>
			<view v-if="userInfo.clockType == 2">
				<view class="sign-text_item">退场时间：{{recordDate}}</view>
				<view class="sign-text_item">打卡地点：{{userInfo.address}}</view>
			</view>
		</view>
		<view v-if="userInfo.flag == 0" class="sign-text">
			<view class="sign-text_item">根据人脸识别认证，未匹配到结果，请检查工人是否退场或者上传近照是否清晰</view>
		</view>

		<view v-if="userInfo.flag == 0" class="button">
			<button type="default" @click="resignUp">重新考勤</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 自定义上传图片样式
				imageStyles: {
					width: 375,
					height: 238,
				},
				userInfo:{
					flag:0,
					userID:""
				},
				recordDate:""
			}
		},
		async onLoad(option) {
			debugger
			this.userInfo = JSON.parse(option.userInfo)
			console.log(this.userInfo);
			console.log(option.userInfo)
			
			let aaa = JSON.parse(option.userInfo)
			this.userInfo = JSON.parse(option.userInfo)
			this.userInfo.userID = this.userInfo.id
			this.userInfo.clockLocation = this.userInfo.address
			if(this.userInfo.flag ==1){
				await uni.request({
					url: 'http://116.205.142.103:8808/labor/system/clock/inserClock', //仅为示例，非真实的接口地址
					method: 'post',
					data: this.userInfo,
					success: (res) => {
						debugger
						let jsonRes = res.data.data
						this.recordDate = jsonRes.clockInTime
						console.log(jsonRes);
						
					}
				})
			}
		},
		methods: {
			
			// 提交上传身份证图片校验
			resignUp() {
				// console.log(1111);
				// var pages = getCurrentPages();
				// console.log("pages", pages);
				uni.reLaunch({
					url: "/pages/signUp/signUp"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 30rpx;
	}

	.sign-result {
		height: 100rpx;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		font-size: 40rpx;
		margin-bottom: 20rpx;
	}

	.sign-text {
		padding: 0 60rpx;

		.sign-text_item {
			// flex-grow: 1;
			text-align: left;
			font-size: 36rpx;
			text-align: left;
		}
	}

	.container {
		width: 632rpx;
		height: 400rpx;
		border: 1rpx dashed #666;
		margin-bottom: 50rpx;
		text-align: center;
		position: relative;
		overflow: hidden;
		box-sizing: border-box;


		.container-icons {
			position: absolute;
			top: 80rpx;
			left: 0;
			right: 0;
			margin: auto;
		}

		.container-tip {
			position: absolute;
			bottom: 20rpx;
			left: 0;
			right: 0;
			margin: auto;
		}

		.image {}
	}

	.submit {
		width: 600rpx;
		margin-top: 50rpx;
	}

	.group-info_upload {
		padding: 10px;
		padding-top: 0;
		width: 100%;
		height: 100%;
		background-color: red;
		position: absolute;
		top: 0;
		left: 0;
		opacity: 0;
		// background-color: red;
	}

	.button {
		width: 600rpx;
		margin: 60rpx auto 0;
		border-radius: 10rpx;
	}

	uni-button[type=default] {
		background-color: #13BC75 !important;
		color: white;
	}
</style>
